<?php
    if(isset($_GET['id']))
    {
        $id = $_GET['id'];
        require_once('../Database/Database.php');
        $db = new Database();
        $db->Connect();
        $shortcut = $db->SelectColumns('Series', 'Shortcut', 'ID_Series = ' . $id);
        if($shortcut)
        {
            $shortcut = $shortcut[0]->Shortcut;
?>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="css/default.css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Fairplay-Ranking | Ranking - ALPHA</title>
    </head>
    <body>
        <div id="header">Fairplay-Ranking</div>
        <div id="main">
            <table>
                <tr>
                    <td>Platz</td>
                    <td>Fahrer</td>
                    <td>Rennen</td>
                    <td>Strafpunkte</td>
                </tr>
                <?php
                    $drivers = $db->Select($shortcut . '_drivers', '', 'Penalty_Points', 'ASC');

                    if($drivers > 0)
                    {
                        $count = 0;
                        foreach($drivers as $driver)
                        {
                            $count++;
                            // Fahrer ohne Startlizenz -> inaktiv..
                            if($driver->Active != 0)
                            {
                                echo '<tr class="active_driver">';
                            }
                            else
                            {
                                echo '<tr class="inactive_driver">';
                            }

                            $name_string = '<a href="../../index.php?option=com_users&view=profile&user_id=' . $driver->JID .
                                '" target="_blank">' . htmlentities($driver->Name) . '</a>';

                            echo '<td>' . $count . '</td>';
                            echo '<td>' . $name_string. '</td>';
                            echo '<td>' . $driver->Races . '</td>';
                            echo '<td>' . $driver->Penalty_Points . '</td>';
                            echo '</tr>';
                        }
                    }
                    else
                    {
                        echo 'No data.';
                    }
                ?>
            </table>
        </div>
        <div id="footer"></div>

    </body>
</html>
<?php
        }
        else
        {
            echo 'Ung&uuml;ltige Serien ID.';
        }
    }
    else
    {
        echo 'ERROR';
    }
?>